package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.MyFabulous;
import cn.wolfcode.trip.base.query.MyFabulousQueryObject;
import cn.wolfcode.trip.base.service.IMyFabulousService;
import cn.wolfcode.trip.base.util.JSONResult;
import cn.wolfcode.trip.base.util.UserContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/myFabulousCount")
public class FabulousCountController {
    @Autowired
    private IMyFabulousService myFabulousService;

    /**
     * 查询攻略、游记，日报详细点赞情况
     * @param qo
     * @return
     */
    @GetMapping
    public int queryFabulousCount(MyFabulousQueryObject qo) {
        qo.setPageSize(0);
        qo.setState(1);
        return myFabulousService.queryFabulousCount(qo);
    }
    @GetMapping("/{fabulous}")
    public JSONResult checkHasFabulous(MyFabulousQueryObject qo){
        JSONResult result = new JSONResult();
        qo.setUserId(UserContext.getCurrentUser().getId());
        MyFabulous myFabulous = myFabulousService.checkHasFabulous(qo);
        if (myFabulous != null){
            return result;
        }else {
            return result.mark("");
        }
    }
}
